﻿using System;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
using XFGameFramework.ExcelSystem;

namespace XFGameFramework.ScriptableObjectSystem
{
    [Serializable]
    public class IconInfo 
    {
        public string projectName;
        public string iconName;
    }

    /// <summary>
    /// 默认配置数据
    /// </summary> 
    public class ScriptableObjectData : ScriptableObject
    {

        /// <summary>
        /// 当前数据所在的配表
        /// </summary>
        [Tooltip("当前数据所在的配表")]
        [Header("当前数据所在的配表")]
#if UNITY_EDITOR
        [CustomConfigDataParentGUI]
#endif
        [ExcelIgnore]
        public ScriptableObjectConfigs parent;

        /// <summary>
        /// ID(唯一标识,不可重复)
        /// </summary>
        [Tooltip("ID(唯一标识,不可重复)")]
        [Header("ID(唯一标识,不可重复)")]
#if UNITY_EDITOR
        [CustomConfigDataIDGUI()]
#endif
        public int id;

        /// <summary>
        /// 名称
        /// </summary>
        [Tooltip("名称")]
        [Header("名称")]
        public string config_name;

        /// <summary>
        /// 图标
        /// </summary>
        [Tooltip("图标")]
        [Header("图标")]
#if UNITY_EDITOR
        [CustomConfigDataIconGUI]
#endif
        public IconInfo icon;

        /// <summary>
        /// 描述
        /// </summary>
        [Tooltip("描述")]
        [Header("描述")]
        [TextArea(3,10)]
        public string des;


       
#if UNITY_EDITOR
        /// <summary>
        /// 插件内部使用方法
        /// </summary>
        public void Rename() 
        {
            string asset_path = AssetDatabase.GetAssetPath(this);

            string current_name = AssetNameTools.GetName(id.ToString(), System.IO.Path.GetDirectoryName(asset_path));

            AssetDatabase.RenameAsset(asset_path, current_name);

            AssetDatabase.Refresh();
        } 
#endif

    }
}
